from comm.action import *
from comm.data import *
import time
dr = Drive.open_browser(url_DBshop)

# 1.get() 在当前窗口访问新的url
# time.sleep(2)
# dr.get(url_DBshop_admin)
# # 2.back()后退，forward()前进，refresh()刷新
# time.sleep(2)
# dr.back()
# time.sleep(2)
# dr.forward()
# time.sleep(2)
# dr.refresh()

# 3.maxmize_window()最大化窗口，minimize_window()最小化窗口，set_window_size设置窗口大小
# time.sleep(2)
# dr.minimize_window()
# time.sleep(2)
# dr.maximize_window()
# time.sleep(2)
# dr.set_window_size(600,600)

# # 4.获取类
# url = dr.current_url   #获取当前窗口的url
# print(url)
# handler = dr.current_window_handle  #获取当前窗口的ID
# print(handler)
# handles = dr.window_handles #获取所有窗口的ID
# print(handles)


# 5.execute_script()  执行js脚本
# dr.execute_script('alert("警告")')
time.sleep(2)
dr.execute_script(f'window.open("{url_DBshop_admin}")')
time.sleep(2)
dr.execute_script(f'window.open("https://www.bilibili.com/")')
handles=dr.window_handles
print(handles)

# 6.close()   关闭当前(第一个打开的)窗口，quit()关闭浏览器
time.sleep(2)
dr.close()
time.sleep(5)
dr.quit()